var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, o, n) {
    var i, s = arguments.length, a = s < 3 ? e : null === n ? n = Object.getOwnPropertyDescriptor(e, o) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(t, e, o, n); else for (var l = t.length - 1; 0 <= l; l--) (i = t[l]) && (a = (s < 3 ? i(a) : 3 < s ? i(e, o, a) : i(e, o)) || a);
    return 3 < s && a && Object.defineProperty(e, o, a), a;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("GameConfig"), s = e("GameData"), c = e("AudioManager"), l = e("EquipManager"), d = e("LoadManager"), u = e("RoleManager"), p = e("UIManager"), h = e("WebManager"), f = e("Global"), g = e("MyScrollView"), m = e("HpView"), y = e("PersonView"), v = e("EquipPropsView"), w = e("SkinItemView"), b = cc._decorator, P = b.ccclass, I = b.property, G = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.personView = null, t.propsView = null, t.btns = null, t.alreadyBtn = null, 
        t.useBtn = null, t.upBtn = null, t.equipSprite = null, t.lock = null, t.iconSprite = null, 
        t.descLabel = null, t.costLabel = null, t.nameLabel = null, t.statusLabel = null, 
        t.limitLabel = null, t.numLabel = null, t.up = null, t.down = null, t.hpView = null, 
        t.nums = [], t.ups = [], t.downs = [], t.numPool = new cc.NodePool(), t.upPool = new cc.NodePool(), 
        t.downPool = new cc.NodePool(), t.idx = 0, t.value = null, t.type = f.RewardType.PIECE, 
        t.num = 100, t;
    }
    return i(t, e), t.prototype.onEnable = function() {
        this.refresh(this.idx);
    }, t.prototype.onDisable = function() {
        this.removeAll();
    }, t.prototype.onClickUp = function() {
        var t;
        if (c.default.getInstance().playAudio("按钮2"), h.default.getInstance().sentLog("点击皮肤界面升级装备按键"), 
        this.type == f.RewardType.DIAMOND) {
            if (s.GD.diamond < this.num) return void (f.G.platform != f.Platform.XiaoDu ? p.default.getInstance().loadPopPnl("diamond", {
                num: 100,
                view: this
            }) : p.default.getInstance().showToast({
                str: "钻石不足"
            }));
            s.GD.diamond -= this.num;
        } else if (this.type == f.RewardType.PIECE) {
            if (s.GD.piece < this.num) return void (s.GD.pieceCount < r.GC.maxPieceCount && f.G.platform != f.Platform.XiaoDu ? p.default.getInstance().loadPopPnl("piece", {
                num: r.GC.pieceNum,
                view: this
            }) : GA.PA && GA.PA.showToast ? null === (t = null === (e = GA.PA) || void 0 === e ? void 0 : e.showToast) || void 0 === t || t.call(e, {
                title: "碎片不足",
                icon: "none"
            }) : p.default.getInstance().showToast({
                str: "碎片不足"
            }));
            s.GD.piece -= this.num;
        }
        l.default.getInstance().addEquip(this.idx);
        var e = l.default.getInstance().getConfig(this.idx);
        l.default.getInstance().doEquip(this.idx, e.type), this.removeAll(), this.refresh(this.idx), 
        cc.systemEvent.emit("equip_warn", !1);
    }, t.prototype.onClickChange = function() {
        c.default.getInstance().playAudio("按钮2"), h.default.getInstance().sentLog("点击皮肤界面更换装备按键");
        var t = l.default.getInstance().getConfig(this.idx);
        l.default.getInstance().doEquip(this.idx, t.type), this.removeAll(), this.refresh(this.idx), 
        cc.systemEvent.emit("equip_warn", !1);
    }, t.prototype.onToggle = function(t) {
        t = t.getComponent(w.default).__itemID;
        t <= this.propsView.itemList.length && this.refresh(t);
    }, t.prototype.start = function() {
        this.scrollView.content.getComponent(cc.ToggleContainer).toggleItems[this.idx].isChecked = !0;
    }, t.prototype.refresh = function(t) {
        this.idx = t;
        var e, o = l.default.getInstance().getConfig(t);
        this.nameLabel.string = o.name, this.descLabel.string = o.desc, this.refreshSkin(t), 
        l.default.getInstance().isHas(t) ? (e = l.default.getInstance().getData(t), this.btns.active = !0, 
        this.propsView.node.active = !0, this.lock.active = !1, this.statusLabel.string = "LV" + e.lv, 
        this.refreshBtn(t), this.setValue(this.getValue(s.GD.gunIdx, s.GD.personIdx, t, e.lv)), 
        this.refreshLabel(), this.showLabel(this.getValue(s.GD.gunIdx, s.GD.personIdx, t, Math.min(e.lv + 1, 30)))) : (0 == o.options.getType || 1 == o.options.getType ? (this.btns.active = !0, 
        this.propsView.node.active = !1, this.lock.active = !0, this.limitLabel.string = o.limit, 
        this.costLabel.string = o.options.num, this.num = o.options.num, this.refreshBtn(t)) : (this.propsView.node.active = !1, 
        this.lock.active = !0, this.limitLabel.string = o.limit, f.G.getRank(s.GD.level).r >= o.options.num ? (this.btns.active = !0, 
        this.costLabel.string = "领取", this.num = 0, this.refreshBtn(t)) : this.btns.active = !1), 
        this.statusLabel.string = "还未获得");
    }, t.prototype.setValue = function(t) {
        this.value = t;
    }, t.prototype.getValue = function(t, e, o, n) {
        return {
            props: l.default.getInstance().getConfig(o).props.map(function(t) {
                return l.default.getInstance().getProps(n, t);
            }),
            hp: u.default.getInstance().getHp(t, e),
            lv: n
        };
    }, t.prototype.refreshLabel = function(t) {
        void 0 === t && (t = this.value), this.propsView.init(t.props), this.hpView.init(t.hp), 
        this.num = l.default.getInstance().getCost(t.lv), this.costLabel.string = this.num.toString();
    }, t.prototype.showLabel = function(t) {
        var o = this;
        t.props.forEach(function(t, e) {
            t = o.propsView.getOffect(o.value.props[e], t);
            0 != t && o.append(t, o.propsView.getParent(e));
        });
    }, t.prototype.refreshBtn = function(t) {
        var e, o;
        l.default.getInstance().isHas(t) ? (this.useBtn.interactable = !0, e = l.default.getInstance().getData(t), 
        o = l.default.getInstance().getConfig(t), l.default.getInstance().isEquip(t, o.type) ? (e.lv < 30 ? this.upBtn.interactable = !0 : this.upBtn.interactable = !1, 
        this.useBtn.node.active = !1, this.alreadyBtn.active = !0) : (this.upBtn.interactable = !1, 
        this.useBtn.node.active = !0, this.alreadyBtn.active = !1)) : (this.upBtn.interactable = !0, 
        this.useBtn.node.active = !0, this.useBtn.interactable = !1, this.alreadyBtn.active = !1);
    }, t.prototype.refreshSkin = function(t) {
        var e = l.default.getInstance().getConfig(t), o = l.default.getInstance().getData(t);
        d.default.getInstance().loadSpriteFrame({
            url: "image/equip/" + (e.pre + (o.form + 1) + e.suf),
            sprite: this.equipSprite
        }), this.personView.initEquip(t, e.type);
    }, t.prototype.append = function(t, e) {
        var o, n = this.getNum();
        n.parent = e, n.setPosition(cc.v2(200, 0)), this.nums.push(n), 0 < t ? (n.color = cc.Color.GREEN, 
        n.getComponent(cc.Label).string = "+" + t, (o = this.getUp()).parent = e, o.setPosition(cc.v2(250, 0)), 
        this.ups.push(o)) : (n.color = cc.Color.RED, n.getComponent(cc.Label).string = "" + t, 
        (t = this.getDown()).setPosition(cc.v2(250, 0)), t.parent = e, this.downs.push(t));
    }, t.prototype.removeAll = function() {
        for (;0 < this.nums.length; ) this.numPool.put(this.nums.pop());
        for (;0 < this.ups.length; ) this.upPool.put(this.ups.pop());
        for (;0 < this.downs.length; ) this.downPool.put(this.downs.pop());
    }, t.prototype.getNum = function() {
        return 0 < this.numPool.size() ? this.numPool.get() : cc.instantiate(this.numLabel.node);
    }, t.prototype.getUp = function() {
        return 0 < this.upPool.size() ? this.upPool.get() : cc.instantiate(this.up);
    }, t.prototype.getDown = function() {
        return 0 < this.downPool.size() ? this.downPool.get() : cc.instantiate(this.down);
    }, a([ I(y.default) ], t.prototype, "personView", void 0), a([ I(v.default) ], t.prototype, "propsView", void 0), 
    a([ I(cc.Node) ], t.prototype, "btns", void 0), a([ I(cc.Node) ], t.prototype, "alreadyBtn", void 0), 
    a([ I(cc.Button) ], t.prototype, "useBtn", void 0), a([ I(cc.Button) ], t.prototype, "upBtn", void 0), 
    a([ I(cc.Sprite) ], t.prototype, "equipSprite", void 0), a([ I(cc.Node) ], t.prototype, "lock", void 0), 
    a([ I(cc.Sprite) ], t.prototype, "iconSprite", void 0), a([ I(cc.Label) ], t.prototype, "descLabel", void 0), 
    a([ I(cc.Label) ], t.prototype, "costLabel", void 0), a([ I(cc.Label) ], t.prototype, "nameLabel", void 0), 
    a([ I(cc.Label) ], t.prototype, "statusLabel", void 0), a([ I(cc.Label) ], t.prototype, "limitLabel", void 0), 
    a([ I(cc.Label) ], t.prototype, "numLabel", void 0), a([ I(cc.Node) ], t.prototype, "up", void 0), 
    a([ I(cc.Node) ], t.prototype, "down", void 0), a([ I(m.default) ], t.prototype, "hpView", void 0), 
    a([ P ], t);
}(g.default);

n.default = G;